<?php
    include_once("checkAuthenticationAction.php");
    include_once("../service/userService.php");
    $title = $_POST["usergroupTitle"];
    $edit_usergroup_id = $_POST["edit_usergroup_id"];
	$privileges = isset($_POST["privileges_cbx"])?$_POST["privileges_cbx"]:array();
    updateGroupDetail($edit_usergroup_id,$title);
    if(unassignAllPermissionOfUserGroup($edit_usergroup_id)){
        assignPermissionOfUserGroup($edit_usergroup_id,$privileges);    
    }
	echo "<script>window.location.href='../admin/user-group-detail.php?action=9&id=".$edit_usergroup_id."';</script>";
    
?>